import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/4/26
 * Time:19:22
 **/
public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int y = sc.nextInt();
            int m = sc.nextInt();
            int d = sc.nextInt();
            int day = outDay(y, m, d);
            System.out.println(day);
        }
    }

    /**
     * 每日一题-计算日期到天数转换
     * @param y
     * @param m
     * @param d
     * @return
     */
    private static int outDay(int y, int m, int d) {
        int[] day = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};//每月的天数
        if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) {
            day[1] = 29;//闰年二月为29天
        }
        if (y<=0||m<=0||m>12||d<=0||d>day[m-1]){
            return -1;//不合法的日期
        }
        int sum = 0;
        for (int i = 0; i < m-1; i++) {
            sum += day[i];//月份之前的天数
        }
        return sum + d;//加上天数
    }
}
